importScripts("./linemeshtessellator.js");

var tessellator = new LineMeshTessellator();

self.onmessage = function(event) {
	
    var message = event.data;

    var meshOptions = new LineMeshOptions();
	meshOptions.setLineWidth(message.lineWidth);
    
	var meshDatas = tessellator.batchProcess(message.geoJsonData.features,message.center,meshOptions, message.needs2World);

    postMessage({'meshDatas':meshDatas,'message':message});
}


// const WORLD_SIZE = 2 * Math.PI * 6378137;
// const coordSys = new CoordSys();
// function projectToWorld(coords) {

//     // Spherical mercator forward projection, re-scaling to WORLD_SIZE
//     var cx = coordSys.mercatorXfromLng(coords[0]);
//     var cy = coordSys.mercatorYfromLat(coords[1]);
//     var projected = [ cx * WORLD_SIZE, cy * WORLD_SIZE ];
//     var pixelsPerMeter = coordSys.projectedUnitsPerMeter(coords[1]);
//     //z dimension
//     var height = coords[2] || 0;
//     projected.push(height * pixelsPerMeter);
//     var result = new Vector3(projected[0], projected[1], projected[2]);
//     return result;
// }

